/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package docPlum.impl;

import docPlum.Decision;
import docPlum.Dependency;
import docPlum.DocPlumPackage;
import docPlum.DocTopic;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectResolvingEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Dependency</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link docPlum.impl.DependencyImpl#getExpectedDecision <em>Expected Decision</em>}</li>
 *   <li>{@link docPlum.impl.DependencyImpl#getSource <em>Source</em>}</li>
 *   <li>{@link docPlum.impl.DependencyImpl#getAffectedto <em>Affectedto</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class DependencyImpl extends EObjectImpl implements Dependency {
	/**
	 * The default value of the '{@link #getExpectedDecision() <em>Expected Decision</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getExpectedDecision()
	 * @generated
	 * @ordered
	 */
	protected static final String EXPECTED_DECISION_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getExpectedDecision() <em>Expected Decision</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getExpectedDecision()
	 * @generated
	 * @ordered
	 */
	protected String expectedDecision = EXPECTED_DECISION_EDEFAULT;

	/**
	 * The cached value of the '{@link #getSource() <em>Source</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSource()
	 * @generated
	 * @ordered
	 */
	protected Decision source;

	/**
	 * The cached value of the '{@link #getAffectedto() <em>Affectedto</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAffectedto()
	 * @generated
	 * @ordered
	 */
	protected EList<DocTopic> affectedto;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected DependencyImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return DocPlumPackage.Literals.DEPENDENCY;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getExpectedDecision() {
		return expectedDecision;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setExpectedDecision(String newExpectedDecision) {
		String oldExpectedDecision = expectedDecision;
		expectedDecision = newExpectedDecision;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, DocPlumPackage.DEPENDENCY__EXPECTED_DECISION, oldExpectedDecision, expectedDecision));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Decision getSource() {
		if (source != null && source.eIsProxy()) {
			InternalEObject oldSource = (InternalEObject)source;
			source = (Decision)eResolveProxy(oldSource);
			if (source != oldSource) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, DocPlumPackage.DEPENDENCY__SOURCE, oldSource, source));
			}
		}
		return source;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Decision basicGetSource() {
		return source;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setSource(Decision newSource) {
		Decision oldSource = source;
		source = newSource;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, DocPlumPackage.DEPENDENCY__SOURCE, oldSource, source));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<DocTopic> getAffectedto() {
		if (affectedto == null) {
			affectedto = new EObjectResolvingEList<DocTopic>(DocTopic.class, this, DocPlumPackage.DEPENDENCY__AFFECTEDTO);
		}
		return affectedto;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case DocPlumPackage.DEPENDENCY__EXPECTED_DECISION:
				return getExpectedDecision();
			case DocPlumPackage.DEPENDENCY__SOURCE:
				if (resolve) return getSource();
				return basicGetSource();
			case DocPlumPackage.DEPENDENCY__AFFECTEDTO:
				return getAffectedto();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case DocPlumPackage.DEPENDENCY__EXPECTED_DECISION:
				setExpectedDecision((String)newValue);
				return;
			case DocPlumPackage.DEPENDENCY__SOURCE:
				setSource((Decision)newValue);
				return;
			case DocPlumPackage.DEPENDENCY__AFFECTEDTO:
				getAffectedto().clear();
				getAffectedto().addAll((Collection<? extends DocTopic>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case DocPlumPackage.DEPENDENCY__EXPECTED_DECISION:
				setExpectedDecision(EXPECTED_DECISION_EDEFAULT);
				return;
			case DocPlumPackage.DEPENDENCY__SOURCE:
				setSource((Decision)null);
				return;
			case DocPlumPackage.DEPENDENCY__AFFECTEDTO:
				getAffectedto().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case DocPlumPackage.DEPENDENCY__EXPECTED_DECISION:
				return EXPECTED_DECISION_EDEFAULT == null ? expectedDecision != null : !EXPECTED_DECISION_EDEFAULT.equals(expectedDecision);
			case DocPlumPackage.DEPENDENCY__SOURCE:
				return source != null;
			case DocPlumPackage.DEPENDENCY__AFFECTEDTO:
				return affectedto != null && !affectedto.isEmpty();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (expectedDecision: ");
		result.append(expectedDecision);
		result.append(')');
		return result.toString();
	}

} //DependencyImpl
